package com.gooluke;

import com.gooluke.policy.MyAbortPolicy;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @author gooluke
 * description
 * datetime 2025-04-07 22:07
 */
public class Main {
    public static void main(String[] args) {
        MyThreadPool threadPool = new MyThreadPool(2,4, 1, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new MyAbortPolicy());
        for (int i = 0; i < 20; i++) {
            final int fi = i;
            threadPool.execute(()->{
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + " 执行了代码 " + fi);
            });
        }
        System.out.println("主线程没有被阻塞");
    }
}
